
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __BOARD_H
#define __BOARD_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"

/* Private includes ----------------------------------------------------------*/

/* Exported types ------------------------------------------------------------*/


/* Exported constants --------------------------------------------------------*/

/* Exported macro ------------------------------------------------------------*/
#define SDCARD_LED_PORT    GPIOC
#define SDCARD_LED_PIN     GPIO_PIN_1

#define FLAG_LED_PORT      GPIOC
#define FLAG_LED_PIN       GPIO_PIN_0
/* Exported functions prototypes ---------------------------------------------*/
int bsp_sdcard_led_init(void);
static inline int bsp_sdcard_led_toggle(void)
{
    HAL_GPIO_TogglePin(SDCARD_LED_PORT, SDCARD_LED_PIN);
    return 0;
}
static inline int bsp_sdcard_led_on(void)
{
    HAL_GPIO_WritePin(SDCARD_LED_PORT, FLAG_LED_PIN, GPIO_PIN_RESET);
    return 0;
}
static inline int bsp_sdcard_led_off(void)
{
    HAL_GPIO_WritePin(SDCARD_LED_PORT, SDCARD_LED_PIN, GPIO_PIN_SET);
    return 0;
}

int bsp_sdcard_isready(void);
int bsp_sdcard_init(void);
int bsp_sdcard_read(uint8_t lun, uint8_t *buf, uint32_t BA, uint16_t count);
int bsp_sdcard_write(uint8_t lun, uint8_t *buf, uint32_t BA, uint16_t count);

int bsp_flag_led_init(void);
static inline int bsp_flag_led_toggle(void)
{
    HAL_GPIO_TogglePin(FLAG_LED_PORT, FLAG_LED_PIN);
    return 0;
}
static inline int bsp_flag_led_on(void)
{
    HAL_GPIO_WritePin(FLAG_LED_PORT, FLAG_LED_PIN, GPIO_PIN_RESET);
    return 0;
}
static inline int bsp_flag_led_off(void)
{
    HAL_GPIO_WritePin(FLAG_LED_PORT, FLAG_LED_PIN, GPIO_PIN_SET);
    return 0;
}

/* Private defines -----------------------------------------------------------*/


#ifdef __cplusplus
}
#endif

#endif /* __BOARD_H */